#ifndef NETWORL_SYNCABLE_H
#define NETWORL_SYNCABLE_H

#include "../../../Base/LockableMutex.h"
#include "../../../Base/UsesCharArray.h"

namespace mp_net
{
	using mp_base::LockableMutex;
	using mp_base::UsesCharArray;

	enum class NetworkSyncStatus : char {
		SYNCED		= 0x01,
		DESYNCED	= 0x00,
		ADDED		= 0x02,
		REMOVED		= 0x03,
		//--
		UNKNOWN		= 0xFF
	};

	enum class NetworkSyncDirection : char {
		OUT		= 0x00,
		IN		= 0x01,
		IN_OUT	= 0x02,
		//--
		UNKNOWN = 0xFF
	};

	class NetworkSyncable : public LockableMutex, public UsesCharArray
	{
	public:

		NetworkSyncable() :LockableMutex()
			{ m_syncDirection = NetworkSyncDirection::UNKNOWN;
			m_syncStatus = NetworkSyncStatus::UNKNOWN;}

		NetworkSyncable(NetworkSyncDirection direction) :LockableMutex()
			{ m_syncDirection = direction;
			m_syncStatus = NetworkSyncStatus::UNKNOWN;}

		virtual ~NetworkSyncable(){}

		NetworkSyncStatus GetSyncStatus()
			{return m_syncStatus;}
		NetworkSyncDirection  GetSyncDirection()
			{return m_syncDirection;}

		virtual void GetCharArray(
			char* data, int& arraySize)=0;
		virtual void SyncWithCharArray(
			const char* data, const int arraySize)=0;

	protected:
		volatile NetworkSyncStatus	m_syncStatus;
		NetworkSyncDirection		m_syncDirection;
	};
}
#endif